#include<bits/stdc++.h>
using namespace std;

const int N=200100;
int T,n,a[N],l[2];//the last red,the last blue,0--red,1--blue
long long ans;

void dfs(int k,long long sum)
{
    if(k==n+1){ans=max(ans,sum);return ;}
    for(int i=0;i<=1;i++)
    {
        if(l[i]==0)
        {
            l[i]=k;
            dfs(k+1,sum);
            l[i]=0;
        }
        else
        {
            int j=l[i];
            l[i]=k;
            if(a[k]==a[j])dfs(k+1,sum+a[j]);
            else dfs(k+1,sum);
            l[i]=j;
        }
    }
}

int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>T;
    int i;
    while(T--)
    {
        cin>>n;
        for(i=1;i<=n;i++)cin>>a[i];
        ans=l[0]=l[1]=0;
        dfs(1,0);
        cout<<ans<<endl;
    }
    return 0;
}
